
class Singletonlazy{
    //若不获取实例就不实例化
    private static Singletonlazy instance=null;
    //只会在首次调用getInstance(获取实例对象)的时候才实例化一个对象出来
    public static Singletonlazy getInstance(){
        if(instance == null) {
            synchronized (Singletonlazy.class) {
                if (instance == null) {
                    instance = new Singletonlazy();
                }
            }
        }
        return instance;
    }
}

public class Test4 {
    public static void main(String[] args) {

    }
}
